<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<p class="aui-text-help-sm aui-gutter-column-lg">
    {{'system_backup_tip_label'|i18n}}
</p>
<lv-form [formGroup]="formGroup" class="formGroup">
    <lv-form-item>
        <lv-form-label lvRequired>
            {{'system_launch_time_label' | i18n}}
        </lv-form-label>
        <lv-form-control [lvErrorTip]="baseUtilService.requiredErrorTip">
            <lv-time-picker formControlName="backupTime" lvPlaceholder="HH:mm" [lvFormat]="'HH:mm'"
                [lvFooter]="timePickerFooterTpl">
            </lv-time-picker>
        </lv-form-control>
    </lv-form-item>
    <lv-form-item>
        <lv-form-label lvRequired>
            {{'system_max_self_backup_label' | i18n}}
        </lv-form-label>
        <lv-form-control [lvErrorTip]="keepCountErrorTip">
            <input lv-input type="text" formControlName="keepCount" placeholder="3~20" />
        </lv-form-control>
    </lv-form-item>
    <lv-form-item>
        <lv-form-label lvRequired>
            {{'system_sftp_ip_label' | i18n}}
        </lv-form-label>
        <lv-form-control [lvErrorTip]="baseUtilService.ipErrorTip">
            <input lv-input type="text" formControlName="destIp"
                placeholder="{{'common_ip4_ipv6_placeholder_label' | i18n}}" />
        </lv-form-control>
    </lv-form-item>
    <lv-form-item>
        <lv-form-label lvRequired>
            {{'system_sftp_username_label' | i18n}}
            <i lv-icon="aui-icon-help" lv-tooltip="{{'system_sftp_user_info_label' | i18n}}" lvTooltipPosition="top"
                 class="configform-constraint" lvColorState='true'></i>
        </lv-form-label>
        <lv-form-control [lvErrorTip]="destUsernameErrorTip">
            <input lv-input type="text" formControlName="destUsername" />
        </lv-form-control>
    </lv-form-item>
    <lv-form-item>
        <lv-form-label lvRequired>
            {{'system_sftp_password_label' | i18n}}
        </lv-form-label>
        <lv-form-control [lvErrorTip]="destPwdErrorTip">
            <aui-inupt-with-eye formControlName="destPwd" [lvPasteAllowed]="false"></aui-inupt-with-eye>
        </lv-form-control>
    </lv-form-item>
    <lv-form-item>
        <lv-form-label lvRequired>
            {{'system_sftp_port_label' | i18n}}
        </lv-form-label>
        <lv-form-control [lvErrorTip]="destPortErrorTip">
            <input lv-input type="text" formControlName="destPort" placeholder="1~65535" />
        </lv-form-control>
    </lv-form-item>
    <lv-form-item>
        <lv-form-label>
            {{'system_backup_dest_label' | i18n}}
            <i *ngIf="isCyberengine || isOceanProtect" lv-icon="aui-icon-help" lv-tooltip="{{backupPathTip}}"
                lvTooltipPosition="top"  class="configform-constraint" lvColorState='true'></i>
        </lv-form-label>
        <lv-form-control [lvErrorTip]="destPathErrorTip">
            <input lv-input type="text" formControlName="destPath" />
        </lv-form-control>
    </lv-form-item>
    <lv-form-item>
        <lv-form-label lvRequired>
            {{'system_trap_data_encryption_password_label' | i18n}}
            <i lv-icon="aui-icon-help" lv-tooltip="{{encryptionPasswordTip}}"
                class="configform-constraint" lvColorState='true'></i>
        </lv-form-label>
        <lv-form-control [lvErrorTip]="encryptedPwdErrorTip">
            <aui-inupt-with-eye [lv-tooltip]="pwdComplexTipTpl" lvTooltipTrigger="focus" lvTooltipPosition="topLeft"
                 formControlName="backupPwd" [lvPasteAllowed]="false"></aui-inupt-with-eye>
        </lv-form-control>
    </lv-form-item>
    <lv-form-item>
        <lv-form-label lvRequired>
            {{'system_trap_encryption_confirm_password_label' | i18n}}
        </lv-form-label>
        <lv-form-control [lvErrorTip]="encryptedPwdErrorTip">
            <aui-inupt-with-eye formControlName="confirmPassword" [lvPasteAllowed]="false"></aui-inupt-with-eye>
        </lv-form-control>
    </lv-form-item>
</lv-form>


<ng-template #tipContentTpl>
    <div [innerHTML]="'system_policy_edit_info_label' | i18n"></div>
</ng-template>


<ng-template #pwdComplexTipTpl>
    <span [innerHTML]="pwdComplexTip"></span>
</ng-template>


<ng-template #footerTpl>
    <div class="lv-modal-btns">
        <lv-group lvGutter='8px'>
            <button lv-button lvType='primary' (click)='test()' [disabled]="formGroup.invalid">
                {{ 'common_test_label' | i18n }}
            </button>
            <button lv-button lvType='primary' (click)='ok()' [disabled]="!isTest || formGroup.invalid">
                {{'common_ok_label' | i18n }}
            </button>
            <button lv-button (click)='modal.close()'>
                {{ 'common_cancel_label' | i18n }}
            </button>
        </lv-group>
    </div>
</ng-template>

<ng-template #timePickerFooterTpl>
    <button lv-button lvType="link" class="time-picker-current" (click)="setSysTime()">
        {{'common_current_time_label' | i18n}}
    </button>
</ng-template>
